<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/includes.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>网站管理信息系统</title>
<link href="<c:url value='/css/admin/main.css'/>" rel="stylesheet" type="text/css"/>
<link href="<c:url value='/css/admin/uploadify/uploadify.css'/>" type="text/css" rel="stylesheet" />
<script src="<c:url value='/js/jquery-1.4.2.min.js'/>" type="text/javascript"></script>
<script type="text/javascript" src="<c:url value='/js/admin/uploadify/swfobject.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/admin/uploadify/jquery.uploadify.v2.1.4.min.js'/>"></script>
<script language="javascript" src="<c:url value='/js/admin/My97DatePicker/WdatePicker.js'/>"></script>
<script type="text/javascript">
$(document).ready(function() {
	var itemsNum = $('#itemsNum').val();
	if(itemsNum == '')
	{
		itemsNum = 0;
	}
	$('#uploadify').uploadify({
	    'uploader'  : '<c:url value="/images/uploadify/uploadify.swf"/>',
	    'script'    : '<c:url value="/admin/ajaxFileUpload.nhtml"/>',
	    'cancelImg' : '<c:url value="/images/uploadify/cancel.png"/>',
	    'folder'    : '<c:url value="/customFile/upload"/>',
	    'queueID'        : 'fileQueue',
	    'auto'           : true,
	    'multi'          : true,
	    'simUploadLimit' : 1,
	    'buttonText'     : 'BROWSE',
	    'removeCompleted': false,
	    onComplete:function(event, ID, fileObj, response, data){
	    	var str = "";
	    	str += "<div id='img'><img src='../../"+response+"' width='64px' height='64'/>";
	    	str += "<input name='coupon.couponItems["+itemsNum+"].url' type='hidden' value='"+response+"'/>";
	    	str += "<span>删除</span></div>";
	    	$("#imgArea").append(str);
	    	itemsNum++;
			$('#itemsNum').val(itemsNum);
	    }
	});
  
	$("#couponStartDate").click(chooseDate);
	$("#couponEndDate").click(chooseDate);
});

/*频度选择*/
function chooseDate(){
	var config;
	config={dateFmt:"yyyy-MM-dd"};
	WdatePicker(config);
}
</script>
</head>
<body>
<div class="columns">
    <jsp:include page="/admin/head.nhtml"/>
    <jsp:include page="/admin/menu.nhtml"/>
    <div class="col_main">
		<form:form modelAttribute="couponForm" method="post" id="couponForm" action="couponSave.nhtml"> 
			<form:hidden id="action" path="action"/>
			<form:hidden id="itemsNum"  path="itemsNum"/>
			<div id="col_subview">
			    <div id="tool_box">
			        <span class="button button-main"><span><button type="button" onclick="Inote.Note.submit(this);">保存并关闭</button></span></span>
			        <span class="button button-main"><span><button type="submit" name="submitBtn">立即保存</button></span></span>
			        <span class="button-cancel" style="padding-left: 40px"><a href="javascript:void(0)" onclick="Inote.Note.cancel();">取消编辑</a></span>
			    </div>
			</div>
			<div style="top: 43px;" id="col_viewer" class="col_container">
		        <dl class="fieldset note_form container">
		        	<dt><label>编码：</label></dt>
		        	<dd>
		        		<form:input cssClass="input" id="couponCode" path="coupon.code" maxlength="40"/>
		        		<label>
							所属产品：
							<form:select path="coupon.product.code" items="${productsList}" itemValue="code" itemLabel="name" cssClass="select"  cssStyle="width:150px"/>
						</label>
		        	</dd>
		            <dt><label>名称：</label></dt>
		            <dd><form:input cssClass="input" id="couponName" path="coupon.name" maxlength="40"/></dd>
		            <dt><label>开始时间：</label></dt>
		            <dd><form:input cssClass="input" id="couponStartDate" path="coupon.startDate" maxlength="40"/></dd>
		            <dt><label>结束时间：</label></dt>
		            <dd><form:input cssClass="input" id="couponEndDate" path="coupon.endDate" maxlength="40"/></dd>
		            <dt><label>优惠券：</label></dt>
		            <dd>
		            <div>
		            	 <div style="float:left;margin-right:10px"><input type="file" name="uploadify" id="uploadify" /></div>
		            	 <div id="fileQueue" style="float:left" ></div>
		            </div>
		            </dd>
		             <dt></dt>
		             <dd><div id = "imgArea">
		             	<c:forEach var="item" items="${couponForm.coupon.couponItems }" varStatus="s">
		             		<div id='img'><img src='../../<c:out value='${item.url }'/>' width='64px' height='64'/>
	    					<input name='coupon.couponItems[<c:out value="${s.index }"/>].url' type='hidden' value="<c:out value='${item.url }'/>"/>
	    					<span>删除</span></div>
		             	</c:forEach>
		             </div></dd>
		        </dl>
			</div>
		</form:form>
	</div>
	<jsp:include page="/admin/foot.nhtml"/>
</div>
</body>
</html>